package net.zoneland.knowledge.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import net.zoneland.uniflow.client.impl.SyncProcessServiceClient;
import net.zoneland.uniflow.client.impl.SyncTaskServiceClient;

/**
 * 流程平台配置.
 * @author zmq
 * @date 2021/10/8 15:02
 */
@Configuration
@ConfigurationProperties(prefix = "uniflow")
public class UniflowConfig {
    /**
     * 用户名称.
     */
    private String username;
    /**
     * 密码.
     */
    private String password;
    /**
     * rest接口地址.
     */
    private String url;


    /**
     * 流程业务接口.
     * @return 流程业务接口
     */
    @Bean(name="processClient")
    public SyncProcessServiceClient processServiceClient() {
        SyncProcessServiceClient processServiceClient = new SyncProcessServiceClient(username, password);
        processServiceClient.setServerAddress(url + "/RestProcessService");
        return processServiceClient;
    }

    /**
     * 任务业务接口.
     * @return 任务业务接口
     */
    @Bean(name = "taskClient")
    public SyncTaskServiceClient taskServiceClient() {
        SyncTaskServiceClient taskServiceClient = new SyncTaskServiceClient(username, password);
        taskServiceClient.setServerAddress(url + "/RestTaskService");
        return taskServiceClient;
    }

    /**
     * 获取 用户名.
     * @return 用户名
     */
    public String getUsername() {
        return username;
    }

    /**
     * 设置 用户名.
     * @param username 用户名
     */
    public void setUsername(String username) {
        this.username = username;
    }
    /**
     * 获取 密码.
     * @return 密码
     */
    public String getPassword() {
        return password;
    }
    /**
     * 设置 密码.
     * @param password 密码
     */
    public void setPassword(String password) {
        this.password = password;
    }
    /**
     * 获取 地址.
     * @return 地址.
     */
    public String getUrl() {
        return url;
    }
    /**
     * 设置 地址.
     * @param url 地址
     */
    public void setUrl(String url) {
        this.url = url;
    }
}
